home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / gcl-1.000 / gcl-1 / gcl-1.0 / h / ext_sym.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-03  |  3.5 KB  |  187 lines

  1. /* format of a rsyms output file:
  2. struct lsymbol_table tab;   gives number of symbols, and sum of length of 
  3.              strings 
  4. addr,char[],addr,char[],...
  5. This can be read since the addr is sizeof(int) and the char[] is null
  6. terminated, immediately followed by and addr...
  7. there are tab.n_symbols pairs occurring.
  8.  
  9. */
  10.  
  11.  
  12. #ifdef HAVE_AOUT 
  13. #undef BSD
  14. #undef ATT
  15. #define BSD  
  16. #include HAVE_AOUT 
  17. #endif
  18.  
  19. #ifdef AIX3
  20. #include <a.out.h>
  21. #endif
  22.  
  23. #ifdef COFF_ENCAPSULATE
  24. #undef BSD
  25. #undef ATT
  26. #define BSD
  27. #include "a.out.encap.h"
  28. #endif
  29.  
  30. #ifndef HEADER_SEEK
  31. #define HEADER_SEEK(x)
  32. #endif
  33.  
  34. typedef unsigned int addr;
  35.  
  36. struct node{
  37.   char *string;
  38.   addr address;
  39. #ifdef AIX3
  40.   unsigned short tc_offset;
  41. #endif  
  42. };
  43.  
  44. struct lsymbol_table{
  45.   unsigned int n_symbols ;
  46.   unsigned int tot_leng;};
  47.  
  48. #define SYM_ADDRESS(table,i) ((*(table).ptable))[i].address
  49. #define SYM_STRING(table,i) ((*(table).ptable))[i].string
  50. #define SYM_TC_OFF(table,i) ((*(table).ptable))[i].tc_offset
  51.  
  52. /* typedef struct node *TABL;  */
  53. /* gcc does not like typedef struct node TABL[];*/
  54.  
  55. typedef struct node TABL[]; 
  56.  
  57. struct node * find_sym_ptable();
  58.  
  59.  
  60. #ifdef ATT
  61. #define COFF
  62. #ifndef TEXT_NSCN
  63. #define TEXT_NSCN 1
  64. #define DATA_NSCN 2
  65. #define BSS_NSCN 3
  66. #endif
  67. #endif
  68.  
  69.  
  70. #ifdef ATT
  71. #include <filehdr.h>
  72. #include <scnhdr.h>
  73. #include <syms.h>
  74. /* is aouthdr.h one always here on sysv
  75.    Interactive systems needs it now at least.   I am not sure if
  76.    the others used to include this...
  77.  */
  78. #include <aouthdr.h>
  79. #define MAXPATHLEN 200
  80. #define N_BADMAG(x)  !(ISCOFF(x.f_magic))
  81. #define N_SYMOFF(x) (x).f_symptr
  82. #define NSYMS(x) (x).f_nsyms  
  83. #include <reloc.h>
  84. #endif
  85.  
  86.  
  87.  
  88.  
  89. #define MAXPATHLENGTH 200
  90. #define RDONLY "r"
  91.  
  92. #ifdef BSD
  93. #define filehdr exec
  94. #ifndef AIX
  95. #ifndef reloc  
  96. #define reloc relocation_info
  97. #endif
  98. #endif
  99. #define NSYMS(f) ((unsigned int )((f).a_syms/(sizeof(struct nlist))))
  100.  
  101. #ifndef AIX
  102. #define syment nlist
  103. #endif
  104.  
  105. #ifndef SYMESZ  
  106. #define SYMESZ (sizeof(struct nlist))
  107. #endif
  108.  
  109. #ifndef  SYMNMLEN
  110.   /* no symbols are directly in the table */
  111. #define SYMNMLEN 0  
  112. #endif
  113.  
  114. #ifndef  EXT_and_TEXT_BSS_DAT
  115. #define EXT_and_TEXT_BSS_DAT(p) (((p)->n_type & N_EXT) && \
  116.   ((p)->n_type & (N_TEXT | N_DATA | N_BSS)))
  117. #endif
  118.  
  119. #ifndef SYM_NAME
  120. #define SYM_NAME(x) (my_string_table+(x)->n_un.n_strx)
  121. #endif
  122.  
  123. #ifndef NUM_AUX  
  124. #define NUM_AUX(p) 0
  125. #endif  
  126.  
  127. #ifndef N_RELOFF  
  128. #define N_RELOFF(p) (N_TXTOFF(p) +(p).a_text+(p).a_data )
  129. #endif
  130.  
  131. #define NTYPE(sym) ((sym)->n_type & N_TYPE)
  132.  
  133. #ifndef N_SECTION
  134. #define N_SECTION(sym) (sym->n_type & N_TYPE & ~N_EXT)
  135. #endif 
  136.  
  137. #define N_UNDEF N_UNDF
  138. #endif /*end bsd */
  139.  
  140. #ifdef HPUX
  141. #define nlist nlist_
  142. #undef syment
  143. struct syment {
  144.     long    n_value;
  145.     unsigned char    n_type;
  146.     unsigned char    n_length;
  147.     short    n_almod;
  148.     short    n_unused;
  149.     union { long n_strx;} n_un;
  150. };
  151.  
  152. #endif /* Hp */
  153.  
  154. #ifdef COFF /* sys v */
  155. #ifndef EXT_and_TEXT_BSS_DAT
  156. #define EXT_and_TEXT_BSS_DAT(p) \
  157.  ((1 <= (p)->n_scnum) && ((p)->n_scnum <= 3 ) && (p)->n_sclass == C_EXT)
  158. #endif
  159. #define NUM_AUX(p) (p)->n_numaux
  160. #define N_TXTOFF(p)  section[1].s_scnptr
  161. #define SYM_NAME(p) \
  162.   (((p)->n_zeroes == 0) ? \
  163.         &my_string_table[(p)->n_offset] : \
  164.                ((p)->n_name[SYMNMLEN -1] ? \
  165.                  (strncpy(tem,(p)->n_name,  \
  166.                        SYMNMLEN), \
  167.                   (char *)tem) : \
  168.                   (p)->n_name ))
  169.          
  170. #define NTYPE(sym) (sym)->n_scnum
  171.  
  172. #endif /* COFF */
  173.  
  174. struct  string_address_table
  175. { TABL *ptable;
  176.   unsigned int length;
  177.   unsigned int alloc_length;
  178. };
  179.  
  180. struct string_address_table c_table;
  181. struct string_address_table combined_table;
  182.  
  183. #define PTABLE_EXTRA 20
  184.  
  185. char *malloc();
  186.  
  187.